//循环
function sum (arr) {
    let s = 0;
    for (let i = 0; i < arr.length; i++) {
        s = s + arr[i]
    }
    return s;
}
//递归
function sum(arr) {
    const len = arr.length;
    if (len === 0) {
        return 0
    } else if (len === 1) {
        return arr[0];
    } else {
        return arr[0] + sum(arr.slice(1))
    }
}

//eval
function sum(arr) {
    return eval(arr.join('+'))
}

//reduce
function sum(arr) {
    return arr.reduce(function (total, curr) {
        return total + curr
    })
}
//forEach
function sum(arr) {
    let s=0;
    arr.forEach((val)=>{
        s+=val;
    })
     return s
 }